package com.windfone.web.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.windfone.common.WebVariable;
import com.windfone.model.StaticAbout;
import com.windfone.service.CommonService;

public class StaticAboutAction extends ActionSupport {

	/**	serialVersionUID */
	private static final long serialVersionUID = 1L;
	private CommonService commonService;
	private List<StaticAbout> allStaticAbout;
	private String name;
	private String content;
	private String engligshName;
	private String shortName;
	private StaticAbout bean;	
	private int staticAboutId;
	public int getStaticAboutId() {
		return staticAboutId;
	}

	public void setStaticAboutId(int staticAboutId) {
		this.staticAboutId = staticAboutId;
	}

	public String getName() {
		return name;
	}

	public String getContent() {
		return content;
	}

	public String getEngligshName() {
		return engligshName;
	}

	public StaticAbout getBean() {
		return bean;
	}

	public void setBean(StaticAbout bean) {
		this.bean = bean;
	}

	public String getShortName() {
		return shortName;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public void setEngligshName(String engligshName) {
		this.engligshName = engligshName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public void setCommonService(CommonService commonService) {
		this.commonService = commonService;
	} 

	public List<StaticAbout> getAllStaticAbout() {
		return allStaticAbout;
	}

	public void setAllStaticAbout(List<StaticAbout> allStaticAbout) {
		this.allStaticAbout = allStaticAbout;
	}

	public String beforeUpdateStatic() throws Exception {
		bean = commonService.getStaticAboutByShortName(shortName);
			//commonService.getStaticAboutByKey(staticAboutId);
		return SUCCESS;
	}
	public String beforeUpdateStatic2() throws Exception {
		bean = commonService.getStaticAboutByShortName(shortName);
		//commonService.getStaticAboutByKey(staticAboutId);
		return SUCCESS;
	}
	
	public String staticAboutList() throws Exception {
		allStaticAbout = commonService.getAllStaticAbout();
		return SUCCESS;
	}
	
	public String updateStatic() throws Exception {
		bean = new StaticAbout();
		bean.setId(staticAboutId);
		bean.setContent(content);
		bean.setEngligshName(engligshName);
		bean.setName(name);
		bean.setShortName(shortName);
		commonService.updateStaticAbout(bean);
		if ( shortName.equals("description")) 
			WebVariable.setWebDesc(content);
		if ( shortName.equals("keywords"))
			WebVariable.setWebKeyWord(content);
		return SUCCESS;
	}
	

}
